package com.stu.controller;

import com.stu.bean.User;
import com.stu.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
public class DataController {
    @Autowired
    private UserService userService;

     @Autowired
     private OrdersService ordersService;

     @Autowired
     private GoodsService goodsService;

     @Autowired
     private ImagesService imagesService;

     @Autowired
     private InvitationService invitationService;


    @RequestMapping("/dataLoading")
    @ResponseBody
    public Map<String,String> dataloading(){
        Map<String,String> map=new HashMap<String, String>();
        int usertotal = userService.selectCount();
        int orderstotal = ordersService.selectOrdersCount();
        int goodsTotal = goodsService.selectGoodsTotal();
        int imgCount = imagesService.selectImgCount();
        int invitationCount = invitationService.selectInvitationCount();
        map.put("usertotal",""+usertotal+"");
        map.put("orderstotal",""+orderstotal+"");
        map.put("goodsTotal",""+goodsTotal+"");
        map.put("imgCount",""+imgCount+"");
        map.put("invitationCount",""+invitationCount+"");
        return map;
    }

    @RequestMapping("toindex")
    public String toindex(){
        return "index";
    }

    @RequestMapping("todatahome")
    public String todatahome(){
        return "datahome";
    }

    @RequestMapping("tospgl")
    public String tospgl(){
        return "spgl";
    }

    @RequestMapping("toshowuser")
    public String toshowuser(){
        return "show-user";
    }

    @RequestMapping("toorder")
    public String toorder(){
        return "order";
    }


    @RequestMapping("tohome")
    public String tohome(){
        return "home";
    }


    @RequestMapping("tobk")
    public String tobk(){
        return "bk";
    }


    @RequestMapping("toregister")
    public String toregister(){
        return "register";
    }


    @RequestMapping("tologin")
    public String tologin(){
        return "login";
    }
}
